/*
 * srm 191 div 2 prob 3
 */

import java.util.*;
import java.util.regex.*;
import java.text.*;
import java.math.*;


public class CuboidJoin
{
    int N;
    int[][][] cood;
    long ans = 0;
    
    void fuck (int d) 
    {
	int[][] c = new int[2][3];
	Arrays.fill (c[0], -5000);
	Arrays.fill (c[1], 5000);
	long k = -1L;
	boolean hit = false;
	for (int i = 0; i < N; ++i) {
	    if ((d & (1<<i)) == 0) continue;
	    hit = true;
	    for (int j = 0; j < 3; ++j) {
		if (c[0][j] < cood[i][0][j])
		    c[0][j] = cood[i][0][j];
		if (c[1][j] > cood[i][1][j])
		    c[1][j] = cood[i][1][j];
		if (c[1][j] < c[0][j])
		    return;
	    }
	    k = -k;
	}
	if (!hit)
	    return;
	for (int j = 0; j < 3; ++j)
	    k *= c[1][j] - c[0][j];
	ans += k;
    }
    
    public long totalVolume(int[] cuboids)
    {
	N = cuboids.length/6;
	cood = new int[N][2][3];
	for (int i = 0; i < N; ++i)
	    for (int j = 0; j < 2; ++j)
		for (int k = 0; k < 3; ++k) 
		    cood[i][j][k] = cuboids[6*i+3*j+k];
	for (int i = 1; i <= (1<<N); ++i)
	    fuck (i);
	return ans;
    }
    
    <%:testing-code%>
}
//Powered by KawigiEdit 2.1.4 (beta) modified by pivanof!